<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>国际金融中心 | Log in</title>
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <script src="/pages/base.js"></script>
</head>

<script>
    window.onload = function () {
        if (window.parent.window != window) {
            window.top.location = "/login.html";
        }
    }
</script>

<body class="hold-transition login-page">
<div class="login-box" id="app">
    <div class="login-logo">
        <a href="all-admin-index.html">国际金融中心</a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">登录系统</p>
        <form action="#" method="post">
            <div class="form-group has-feedback">
                <input type="text" name="email" v-model="user.name" class="form-control" placeholder="Email">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" name="password" v-model="user.password" class="form-control" placeholder="密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="row">
                <div class="col-xs-8">
                    <div class="checkbox icheck">
                        <label class=""></label>
                    </div>
                </div>
                <div class="col-xs-4">
                    <button type="button" @click="login" class="btn btn-primary btn-block btn-flat">登录</button>
                </div>
            </div>
        </form>
    </div>
</div>
<script>
    new Vue({
        // 挂载vue对象的页面区域
        el: "#app",
        // 绑定数据
        data: {
            user:{}
        },
        // 函数定义
        methods: {
            login(){
                // 登陆：通过axios发送异步请求，传入json格式数据：{"name":"","password":""}
                axios.post('/login',this.user).then(resp=>{
                    console.log(resp);
                    // 获取后台返回的结果； resp.data 中的data是vue封装的
                    let resultInfo = resp.data;
                    if (resultInfo.success){
                        // 认证成功
                        location.href = '/pages/home/main.html';
                    } else {
                        alert(resultInfo.message);
                    }
                })
            }
        }
    });
</script>



</body>
</html>
